//
//  MYYMeHeadView.m
//  meiyinxiang
//
//  Created by 陈李飞 on 2017/10/23.
//  Copyright © 2017年 hbjApple. All rights reserved.
//

#import "MYYMeHeadView.h"
#import "MYY_Me_Macro.h"
#import "MYYHeadTopView.h"
@interface MYYMeHeadView()


@end
@implementation MYYMeHeadView
-(id)init
{
    self = [super init];
    
    if (self) {
        self.backgroundColor =[UIColor whiteColor];
        
        [self addSubview:self.headView];
        [self.headView  addSubview:self.AvraImageView];
        [self.headView  addSubview:self.nameLable];
        [self addSubview:self.mobileLable];
      //  [self.headView  addSubview:self.categoryLabel];
        [self addSubview:self.fooderView];
        
        [_headView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.right.equalTo(self).with.offset(0);
            make.top.equalTo(self).offset(0);
            make.bottom.equalTo(self).with.offset(-50);
        }];
        
               
        [_AvraImageView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.equalTo(_headView).with.offset(40);
            make.centerY.equalTo(_headView).with.offset(-10);
            make.height.equalTo(@77);
            make.width.equalTo(@77);
        }];
        _AvraImageView.contentMode = UIViewContentModeScaleAspectFill;
        _AvraImageView.layer.masksToBounds = YES;
//        [_nameLable mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.top.equalTo(_AvraImageView.mas_top).with.offset(10);
//            make.left.equalTo(_AvraImageView.mas_right).with.offset(20);
//            make.height.equalTo(@30);
//        }];
      
        
//        [_categoryLabel mas_makeConstraints:^(MASConstraintMaker *make) {
//            make.left.equalTo(_nameLable);
//            make.height.equalTo(@20);
//             make.width.equalTo(@40);
//            make.top.equalTo(_nameLable.mas_bottom).with.offset(10);
//            
//        }];

        
        [_fooderView mas_makeConstraints:^(MASConstraintMaker *make) {
            make.left.and.right.equalTo(self).with.offset(0);
            make.height.equalTo(@50);
            make.bottom.equalTo(self);
        }];
        [_mobileLable mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_nameLable.mas_bottom).with.offset(10);
            make.left.equalTo(_nameLable);
            make.right.equalTo(@-10);
//            make.height.equalTo(@30);
           // make.bottom.equalTo(_fooderView.mas_top).with.offset(0);
            
        }];
        UITapGestureRecognizer *tapScrollView = [[UITapGestureRecognizer alloc] initWithTarget:self action:@selector(editContentText)];
        [_AvraImageView addGestureRecognizer:tapScrollView];
    }
    
    return self;
}

-(void)editContentText
{
    self.ziliaoGes();
}




#pragma mark - property
- (UIImageView *)AvraImageView
{
    if (_AvraImageView == nil) {
        _AvraImageView = [[UIImageView alloc] init];
        _AvraImageView.image =[UIImage imageNamed:@"AppIcon"];
        _AvraImageView.clipsToBounds = YES;
        _AvraImageView.layer.cornerRadius =77/2;
        _AvraImageView.userInteractionEnabled = YES;
        
    }
    return _AvraImageView;
}


- (UILabel *)nameLable
{
    if (_nameLable == nil) {
        _nameLable = [[UILabel alloc] init];
        _nameLable.font = MYYFont(18.0f);
        _nameLable.textColor = [UIColor whiteColor];
       // _nameLable.text = @"陈飞飞";
        
        
    }
    return _nameLable;
}

- (UILabel *)mobileLable
{
    if (_mobileLable == nil) {
        _mobileLable = [[UILabel alloc] init];
        _mobileLable.font = MYYFont(14.0f);
        _mobileLable.textColor = [UIColor whiteColor];
        _mobileLable.numberOfLines = 0;
        _mobileLable.lineBreakMode = 0;
       // _mobileLable.text = @"生活";
    }
    return _mobileLable;
}
- (UILabel *)categoryLabel
{
    if (_categoryLabel == nil) {
        _categoryLabel = [[UILabel alloc] init];
        _categoryLabel.font = MYYFont(10.0f);
        _categoryLabel.textColor = [UIColor whiteColor];
      //  _categoryLabel.text = @"旅行";
        _categoryLabel.layer.cornerRadius = 7.;//边框圆角大小
        _categoryLabel.layer.masksToBounds = YES;
        _categoryLabel.layer.borderColor = [UIColor whiteColor].CGColor;//边框颜色
        _categoryLabel.layer.borderWidth = 1;//边框宽度
        _categoryLabel.textAlignment = NSTextAlignmentCenter;
        
    }
    return _categoryLabel;
}


- (UIView *)headView
{
    if (_headView == nil) {
        _headView = [[UIView alloc] init];
        _headView.backgroundColor =MYYheadColor;
    }
    return _headView;
}
- (UIView *)fooderView
{
    if (_fooderView == nil) {
        _fooderView = [[UIView alloc] init];
        _fooderView.backgroundColor =MYYfootColor;
    }
    return _fooderView;
}

-(void)setHidden:(BOOL)hidden{
    _hidden = hidden;
    if (_hidden) {
        [_nameLable mas_makeConstraints:^(MASConstraintMaker *make) {
            make.centerY.equalTo(_AvraImageView);
            make.left.equalTo(_AvraImageView.mas_right).with.offset(10);
            make.height.equalTo(@30);
        }];
    }else{
        [_nameLable mas_makeConstraints:^(MASConstraintMaker *make) {
            make.top.equalTo(_AvraImageView.mas_top).with.offset(10);
            make.left.equalTo(_AvraImageView.mas_right).with.offset(20);
            make.height.equalTo(@30);
        }];
    }
    
}


/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect {
    // Drawing code
}
*/

@end
